﻿using System;
using SecurityTokenServiceNS;
using System.IdentityModel.Claims;
using System.Collections.ObjectModel;
using System.ServiceModel.Security.Tokens;

namespace IssuedClaimsAddIns
{
	class IssuedClaimsModuleFilter : IIssuedClaimsProcessor
	{
		public void GetIssuedClaims(RST rst, Collection<Claim> claims)
		{
			Collection<Claim> finalClaims = new Collection<Claim>();
			foreach (Claim claim in claims)
				foreach (ClaimTypeRequirement ctr in rst.Claims)
					if (string.Compare(claim.ClaimType, ctr.ClaimType, true) == 0)
					{
						finalClaims.Add(claim);
						break;
					}
			claims = finalClaims;
		}
	}
}
